﻿using Assets.Scripts.DL.Consts;
using Assets.Scripts.DL.Mgrs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Scripts.DL.ComponentScripts {
	public class DangerIcon : MonoBehaviour {
		[SerializeField] Animator animator;
		[SerializeField] AudioSource audioSource;
		public void Init(Vector2 pos) {
			transform.position = pos;
			AudioManager.Play(audioSource, AudioStr.Danger);
			animator.Play("Danger", 0, 0);
		}

		public void Update() {
			if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.9f) {
				ObjectPool.Instance.RecycleObject(ObjPoolStr.DangerIcon, gameObject);
			}
		}
	}
}
